<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2019/2/26
 * Time: 22:38
 */

namespace admin\controllers;


use admin\components\BaseAuthController;
use app\models\Comment;

class CommentController extends BaseAuthController {

    public function beforeAction($action) {
        $this->view->title = \Yii::t('app', 'Comments');
        return parent::beforeAction($action);
    }

    public function actionIndex() {
        $model = new Comment();
        $params = $this->getParam();
        $dataProvider = $model->search($params);

        return $this->render(compact('dataProvider'));
    }

    public function actionSave($id = NULL) {
        /* @var $model Comment */
        $model = $this->findModel($id, Comment::class);
        if (!$model->isNewRecord) {
            $model->status = Comment::YES;
            return $model->save();
        }
        return $this->render(compact('model'));
    }
}